Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for example option passed through env variable #134

Merged
merged 1 commit into from
Feb 26, 2024

Conversation

jraoult
Copy link
Contributor

@jraoult jraoult commented Feb 23, 2024

There is currently no way to set the example option using an env variable. As rightly pointed out here in this issue, DOTENV_CONFIG_PATH is supported thanks to dotenv, but since it is not aware of dotenv-safe's example option this one is ignored.

I added the support for DOTENV_CONFIG_EXAMPLE in dotenv-safe/config.js. I got inspiration from what is done in dotenv/config.js being more restrictive than my initial patch and only explicitly supporting DOTENV_CONFIG_EXAMPLE

config.js is not covered by the current test suite so I'm unsure how to proceed. The manual way of testing is typically the following command:

DOTENV_CONFIG_PATH=src/.deploy.env DOTENV_CONFIG_EXAMPLE=src/.deploy.env.example node --require dotenv/config --require dotenv-safe/config src/myApp.js

It would fail before with Error: ENOENT: no such file or directory, open '.env.example' but is now supported.

closes #126 (comment)

@rolodato rolodato merged commit 26269bc into rolodato:master Feb 26, 2024
3 checks passed
@rolodato
Copy link
Owner

Thanks @jraoult! No worries about the tests for now. I'll release a new version soon.

@rolodato
Copy link
Owner

9.1.0 is now released. Also added support for setting DOTENV_CONFIG_ALLOW_EMPTY_VALUES, for completeness. Thanks again!

@jraoult jraoult deleted the env-config-for-example branch February 26, 2024 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dotenv-safe/config does not support configuration options by environment variable; dotenv/config does
2 participants